import { reqGetSearchList } from '../../api/index';
const actions = {
  async getSearchList({commit},params={}){
    const result = await reqGetSearchList(params)
    if(result.code === 200){
      commit("GETSEARCHLIST",result.data)
    }
  }
}
const mutations = {
  GETSEARCHLIST(state,data){
    state.searchList = data
  }
}
const state = {
  searchList:{},
}

// 计算属性， 在项目中，为了简化数据而生
const getters = {
  // 简化 产品列表数据
  goodsList(state){
    // 加上[] 防止网路过慢或者没网的情况下出错 或者 报警告
    return state.searchList.goodsList || []
  },
  attrsList(state){
    return state.searchList.attrsList || []
  },
  trademarkList(state){
    return state.searchList.trademarkList || []
  },
  total(state){
    return state.searchList.total || []
  }
}

export default{
  namespaced:true,
  actions,
  mutations,
  state,
  getters
}